package dao;

import dataBean.UserInfoDo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by lxl on 2015/10/18.
 */
public interface UserInfoDao {

    @Insert(" insert into user_info(name,level,username)values(#{name},#{level},#{username})")
    public int insertUserInfo( UserInfoDo userInfoDo) ;

    @Select("select * from user_info where username=#{username}")
    public UserInfoDo selectUserInfoByName( String username ) ;

    @Select("select * from user_info where id=#{id}")
    public UserInfoDo selectUserInfoById( int id ) ;

    @Select("select * from user_info")
    public List<UserInfoDo> selectAllUser() ;

    @Select("select *from user_info where level=#{level}")
    public List<UserInfoDo> selectUserByLevel( int level ) ;

    @Select("select * from  user_info where username = (select  username from user where id = #{id})")
    public UserInfoDo selectUserInfoByUserDoId( int id ) ;

    @Select("SELECT user_info.name FROM user_info, course_info WHERE user_info.id = course_info.teacher_id AND course_info.name = #{courseName}")
    public List<String> selectTeacherOnCourse(String courseName);
}
